package changedb;

import java.util.ArrayList;
import java.util.List;

/**
 * A class to represent members.
 *
 * @author Ben Goodwin
 * @version @version 2.0 16/09/2011
 */

public class Member implements Comparable<Member>
{
    private String type, firstName, lastName, email, mobile,
    dobD, dobM, dobY, address1, address2, town, postcode,
    mother, father, school, sosNum, medical, other;
    private List<String> details;

    /**
     * Makes a Member
     */
    public Member(String type, String firstName, String lastName,
    String email, String mobile, String dobD, String dobM,
    String dobY, String address1, String address2, String town,
    String postcode, String mother, String father, String school, String sosNum,
    String medical, String other)
    {
        this.type = type;
        if(!firstName.equals("first name")) this.firstName = firstName;
        else this.firstName = "";
        if(!lastName.equals("last name")) this.lastName = lastName;
        else this.lastName = "";
        if(!email.equals("email")) this.email = email;
        else this.email = "";
        if(!mobile.equals("mobile")) this.mobile = mobile;
        else this.mobile = "";
        if(!dobD.equals("dd")) this.dobD = dobD;
        else this.dobD = "";
        if(!dobM.equals("mm")) this.dobM = dobM;
        else this.dobM = "";
        if(!dobY.equals("yyyy")) this.dobY = dobY;
        else this.dobY = "";
        if(address1.equals("address line 1")) this.address1 = "";
        else this.address1 = address1;
        if(address2.equals("address line 2")) this.address2 = "";
        else this.address2 = address2;
        if(!town.equals("town/city")) this.town = town;
        else this.town = "";
        if(!postcode.equals("postcode")) this.postcode = postcode;
        else this.postcode = "";
        if(!mother.equals("mother's name")) this.mother = mother;
        else this.mother = "";
        if(!father.equals("father's name")) this.father = father;
        else this.father = "";
        if(!sosNum.equals("emergency telephone")) this.sosNum = sosNum;
        else this.sosNum = "";
        if(!medical.equals("medical information")) this.medical = medical;
        else this.medical = "";
        if(!other.equals("Any other information")) this.other = other;
        else this.other = "";
        details = new ArrayList<String>();
        details.add(type);
        details.add(this.firstName);
        details.add(this.lastName);
        details.add(this.email);
        details.add(this.mobile);
        details.add(this.dobD);
        details.add(this.dobM);
        details.add(this.dobY);
        details.add(this.address1);
        details.add(this.address2);
        details.add(this.town);
        details.add(this.postcode);
        details.add(this.mother);
        details.add(this.father);
        details.add(school);
        details.add(this.sosNum);
        details.add(this.medical);
        details.add(this.other);
    }

    /**
     * Returns the email
     */
    public String getEmail()
    {
        return email;
    }

    public String getName()
    {
        return firstName + " " + lastName;
    }

    /**
     * Overwrites toString
     */
    @Override
    public String toString()
    {
        return firstName + " " + lastName;
    }

    public String getType()
    {
        return type;
    }

    public List<String> getDetails()
    {
        return (ArrayList)details;
    }

    @Override
    public int compareTo(Member m)
    {
        return this.toString().compareTo(m.toString());
    }
}